package com.hxm.meizi.provider;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.blankj.utilcode.utils.StringUtils;
import com.hxm.meizi.R;
import com.hxm.meizi.entity.ZhuanTiName;

import me.drakeet.multitype.ItemViewProvider;

/**
 * Created by hxm on 2017/2/19.
 */

public class ZhuanNameProvider extends ItemViewProvider<ZhuanTiName, ZhuanNameProvider.ZhuanNameHolder> {

    @NonNull
    @Override
    protected ZhuanNameHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View view = inflater.inflate(R.layout.item_zhuan_name_provider, parent, false);
        return new ZhuanNameHolder(view);
    }

    @Override
    protected void onBindViewHolder(@NonNull ZhuanNameHolder holder, @NonNull ZhuanTiName zhuanTiName) {
        holder.tvName.setText(zhuanTiName.getName());
        if (!StringUtils.isEmpty(zhuanTiName.getTag())) {
            holder.tvCategory.setText(zhuanTiName.getTag());
        } else {
            holder.tvCategory.setText(zhuanTiName.getTag());
        }
    }

    static class ZhuanNameHolder extends RecyclerView.ViewHolder {
        private TextView tvCategory, tvName;

        public ZhuanNameHolder(View itemView) {
            super(itemView);
            tvCategory = (TextView) itemView.findViewById(R.id.tv_category);
            tvName = (TextView) itemView.findViewById(R.id.tv_name);
        }
    }
}
